package leo.weixin.util;

import com.thoughtworks.xstream.XStream;

public class BeanUtil {
    /**
     * 将 bean转换为xml
     * @param obj
     * @return
     */
    public static String beanToXml(Object obj) {
        if(obj == null) {
            return null;
        }
        XStream stream = new XStream();
        //设置需要处理XstreamAlias("xml")注释的类
        stream.processAnnotations(obj.getClass());
        return stream.toXML(obj);
    }
}
